<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			 var timer = null ;//timer变量记录定时器setInterval的返回值
			var m = 0 //分
			var s = 0//秒
			var sss =0 //毫秒
			
			 
			function gettime() {
				sss++;
				if (sss==99) {
					s+=1;
					sss=0;
				} 
				if(s==59){
					m+=1;
					s=0;
				}
				
				
				
				
				document.querySelector("#m").innerHTML=m;
				document.querySelector("#s").innerHTML=s;
				document.querySelector("#sss").innerHTML=sss;
				
			}
			function st(){
				//开始
				clearInterval(timer);
			  timer= setInterval("gettime()", 1);
			}
			function pau(){				
				//取消定时器
				clearInterval(timer);
			}
			function end(){
				//清零
				document.querySelector("#m").innerHTML="00";
				document.querySelector("#s").innerHTML="00";
				document.querySelector("#sss").innerHTML="00";
			}
		</script>
	</head>
	<body>
		<div id="div1">
			<div id="count">
				<span id="m">00</span>
				<span id="s">00</span>
				<span id="sss">00</span>
			</div>
			<input id="start" type="button" value="开始" onclick="st()" >
			
			<input id="pause" type="button" value="暂停" onclick="pau()">
			<input id="end" type="button" value="停止" onclick="end()">
		</div>
	</body>
</html>
